package com.zretc.emptraining.serviceimpl;

import java.util.List;

import com.zretc.emptraining.dao.CoursePlanDao;
import com.zretc.emptraining.daoimpl.CoursePlanDaoImpl;
import com.zretc.emptraining.dbtools.PageData;
import com.zretc.emptraining.entity.CoursePlan;
import com.zretc.emptraining.service.CoursePlanService;

public class CoursePlanServiceImpl implements CoursePlanService {
	CoursePlanDao cpd = new CoursePlanDaoImpl();

	/**
	 * 增加课程计划
	 */
	@Override
	public boolean addCoursePlan(CoursePlan cp) {
		if (cp == null) {
			return false;
		}
		return cpd.addCoursePlan(cp);
	}

	/**
	 * 删除课程计划
	 */
	@Override
	public boolean delCoursePlan(int cpNo) {
		// TODO Auto-generated method stub
		return cpd.delCoursePlan(cpNo);
	}

	/**
	 * 修改课程计划
	 */
	@Override
	public boolean updCoursePlan(CoursePlan cp) {
		// TODO Auto-generated method stub
		return cpd.updCoursePlan(cp);
	}

	/**
	 * 分页：根据 教员号 精确查询
	 */
	@Override
	public PageData<CoursePlan> getCoursePlansByPage(int page, int pageSize, int teacherNo) {
		// TODO Auto-generated method stub
		// 避免用户输入页码小于1
		if (page < 1) {
			page = 1;
		}
		return cpd.getCoursePlansByPage(page, pageSize, teacherNo);
	}

	/**
	 * 分页：查询所有
	 */
	@Override
	public PageData<CoursePlan> getAllCoursePlansByPage(int page, int pageSize) {
		// TODO Auto-generated method stub
		// 避免用户输入页码小于1
		if (page < 1) {
			page = 1;
		}
		return cpd.getAllCoursePlansByPage(page, pageSize);
	}

	@Override
	public List<CoursePlan> getCoursePlan() {
		// TODO Auto-generated method stub
		return cpd.getCoursePlan();
	}
	
	@Override
	public boolean updCoursePlanStatus(int cpNo, int status) {
		// TODO Auto-generated method stub
		return cpd.updCoursePlanStatus(cpNo, status);
	}

	@Override
	public CoursePlan getCoursePlan(int cpNo) {
		// TODO Auto-generated method stub
		return cpd.getCoursePlanByNo(cpNo);
	}
}
